CREATE TABLE [dbo].[TCFACT]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TCFACT__NU_ANNO__32E0915F] DEFAULT (datepart(year,getdate())),
[TI_AUXI_EMPR] [dbo].[TD_VC_001] NOT NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NOT NULL,
[TI_DOCU] [dbo].[TD_VC_003] NOT NULL,
[NU_DOCU] [dbo].[TD_VC_020] NOT NULL,
[NU_CNTB_EMPR] [dbo].[TD_IN_001_CONT] NOT NULL,
[CO_OPRC_CNTB] [dbo].[TD_VC_003] NOT NULL,
[NU_MESE] [dbo].[TD_IN_002_MESE] NOT NULL,
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[TI_CAMB] [dbo].[TD_VC_003] NOT NULL,
[FA_CAMB] [dbo].[TD_NU_015_006] NOT NULL CONSTRAINT [DF__TCFACT__FA_CAMB__36B12243] DEFAULT ((1.000)),
[FE_DOCU] [dbo].[TD_DT_001] NOT NULL,
[ST_IMPR_FACT] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TCFACT__ST_IMPR___38996AB5] DEFAULT ('N'),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCFACT__FE_USUA___3A81B327] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TCFACT__FE_USUA___3B75D760] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCFACT] ADD CONSTRAINT [CK__TCFACT__FA_CAMB__37A5467C] CHECK (([FA_CAMB]>=(0)))
GO
ALTER TABLE [dbo].[TCFACT] ADD CONSTRAINT [CK__TCFACT__NU_ANNO__33D4B598] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TCFACT] ADD CONSTRAINT [CK__TCFACT__NU_CNTB___34C8D9D1] CHECK (([NU_CNTB_EMPR]>=(1) AND [NU_CNTB_EMPR]<=(99)))
GO
ALTER TABLE [dbo].[TCFACT] ADD CONSTRAINT [CK__TCFACT__NU_MESE__35BCFE0A] CHECK (([NU_MESE]>=(0) AND [NU_MESE]<=(13)))
GO
ALTER TABLE [dbo].[TCFACT] ADD CONSTRAINT [CK__TCFACT__ST_IMPR___398D8EEE] CHECK (([ST_IMPR_FACT]='N' OR [ST_IMPR_FACT]='S'))
GO
ALTER TABLE [dbo].[TCFACT] ADD CONSTRAINT [XPKTCFACT] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_ANNO], [TI_AUXI_EMPR], [CO_AUXI_EMPR], [TI_DOCU], [NU_DOCU], [NU_CNTB_EMPR]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TCFACT] ADD CONSTRAINT [FK1_TMPARA_CONT_A_TCFACT] FOREIGN KEY ([CO_EMPR]) REFERENCES [dbo].[TMPARA_CONT] ([CO_EMPR])
GO
